 /*///////////////////////////////////////////////////////////////////////////////
-- Author:      liuhx
-- Created:     Tue Aug 27 08:21:27 CST 2019
-- Description:
-- If you have any question,please email to liuhx@gentlesoft.com.cn
////////////////////////////////////////////////////////////////////////////////*/
package com.ctsi.question.service;

 import com.ctsi.commons.util.UtilValidate;
 import com.ctsi.commons.util.id.UUIDGenerator;
 import com.ctsi.commons.util.response.Page;
 import com.ctsi.framework.mybatis.support.MybatisGenericDao;
 import com.ctsi.question.entity.DayReportLeaderEntity;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;

 import java.util.List;
 import java.util.Map;


/**
 * 日报领导批示表 Service 类
 * @author   liuhx
 * @description  日报领导批示表
 * @created	 Tue Aug 27 08:21:27 CST 2019
 */

@Service
public class DayReportLeaderEntityService {
	private static final Logger logger=LoggerFactory.getLogger(DayReportLeaderEntityService.class);
	@Autowired
	private MybatisGenericDao dao;

	/**
	 * 添加
	 */
	public int insertDayReportLeaderEntity(DayReportLeaderEntity dayReportLeaderEntity){
		if(UtilValidate.isEmpty(dayReportLeaderEntity.getId()))
			dayReportLeaderEntity.setId(UUIDGenerator.getId());
		logger.debug("insert {}",dayReportLeaderEntity);
		return dao.insert(dayReportLeaderEntity);
	}
	/**
	 * 动态更新
	 */
	public int updateDayReportLeaderEntityByPKSelective(DayReportLeaderEntity dayReportLeaderEntity){
		logger.debug("updateByPrimaryKeySelective {}",dayReportLeaderEntity);
		return dao.update(DayReportLeaderEntity.class.getName()+".updateByPrimaryKeySelective", dayReportLeaderEntity);
	}
	/**
	 * 更新
	 */
	public int updateDayReportLeaderEntity(DayReportLeaderEntity dayReportLeaderEntity){
		logger.debug("update {}",dayReportLeaderEntity);
		return dao.update(dayReportLeaderEntity);
	}


	public DayReportLeaderEntity editDayReportLeaderEntityById(String id){
		if(UtilValidate.isEmpty(id))
			return null;
		logger.debug("editById {}",id);
		return (DayReportLeaderEntity)dao.queryForObject(DayReportLeaderEntity.class.getName()+".edit", id);
	}
	/**
	 * 根据ID查找 DayReportLeaderEntity对象
	 */
	public DayReportLeaderEntity findDayReportLeaderEntityById(String id){
		if(UtilValidate.isEmpty(id))
			return null;
		logger.debug("findById {}",id);
		return dao.get(DayReportLeaderEntity.class, id);
	}
	/**
	 * 删除DayReportLeaderEntity对象
	 */
	public int removeDayReportLeaderEntity(String id){
		if(UtilValidate.isNotEmpty(id))
			return dao.delete(DayReportLeaderEntity.class.getName()+".delete", id);
			//return dao.remove(id);
		return 0;
	}

	/**
	 * 详细页查询
	 */
	public DayReportLeaderEntity findByDetail(String id){
		return (DayReportLeaderEntity)dao.queryForObject(DayReportLeaderEntity.class.getName()+".findByDetail",id);
	}

	/**
	 * 多条件查询结果
	 */
	public Page<DayReportLeaderEntity> findByMulitCondition(Map<String,Object> param , int start , int pageSize){
		logger.debug("findByMulitCondition {}",param);
		if(pageSize<0||pageSize>2000)
			pageSize=Page.DEFAULT_PAGE_SIZE;
		if(start!=-1)
			return dao.queryPage(DayReportLeaderEntity.class.getName()+".selectMulitCondition", param, start, pageSize);
		else{
			throw new RuntimeException("参数不正确 !!");
		}
	}

	/**
	 * 多条件查询结果不分页
	 */
	public List<DayReportLeaderEntity> find(Map<String,Object> map){
		logger.debug("find {}",map);
		return (List<DayReportLeaderEntity>)dao.queryForList(DayReportLeaderEntity.class.getName()+".selectByMap",map);
	}

}
